﻿@model AesApplication.Models.StaffingExpertIndexViewModel
@{
    
}


<script type="text/javascript">
    function showQuestionnaire() {
        var selected = document.getElementById("SelectedItem").value;
        var length = document.getElementById("SelectedItem").length;
        
        if (length != 1) {


            for (i = 1; i <= length; i++) {
                if (i != selected) {
                    document.getElementById(i).style.display = "none";
                }
            }
            document.getElementById(selected).style.display = "block";
        }
    }
    
</script>


    

<div style="width: 150px; margin-right:10px;float:left;" >

    <form method="post">
        @if (Model.Questionnaires.Count != 0)
        {
            @Html.DropDownListFor(m => m.SelectedItem, Model.Items, new
            {
                size = "15",
                onchange = "showQuestionnaire()"
            })
            <br />

            <input type="submit" value="Delete" id="delete" />
        }
        else
        {
            <p>Currently there are no Questionnaires. Click new to create one.</p>

        }
    </form>
    <form method="post">
        <input type="submit" value="New" />
    </form>
</div>
@switch(@Model.Items.Count)
{
    case 0:
        //No hidden divs
        
        break;
    case 1:
        //Show the one div
        <div id="1" class=@Model.Questionnaires[0].ID style="width: 500px; margin-right: 10px; float: left;">
            @using (Html.BeginForm("Index", "StaffingExpert", FormMethod.Post))
            {
                @Html.LabelFor(model => model.Questionnaires[0].Name)
                @Html.EditorFor(model => model.Questionnaires[0].Name)
                @Html.HiddenFor(model => model.Questionnaires[0].ID)
                <input type="submit" value="Save" />
            }
        <ol>
            @foreach (var question in @Model.Questionnaires[0].Questions)
            {
            <li>
                <p>@question.GetDisplayText() @Html.ActionLink("Edit", "QuestionCreator", new { QuestionNum = question.Number, QuestionnaireId = @Model.Questionnaires[0].ID })</p>
            </li>
            }
        </ol>
        </div>
        break;
    default:
        //Show the first div,
        <div id="1" class=@Model.Questionnaires[0].ID style="width: 500px; margin-right: 10px; float: left;">
            @using (Html.BeginForm("Index", "StaffingExpert", FormMethod.Post))
               {
                @Html.LabelFor(model => model.Questionnaires[0].Name)
                @Html.EditorFor(model => model.Questionnaires[0].Name)
                @Html.HiddenFor(model => model.Questionnaires[0].ID)
                <input type="submit" value="Save" />
               }
        <ol>
            @foreach (var question in @Model.Questionnaires[0].Questions)
            {
            <li>
                <p>@question.GetDisplayText() @Html.ActionLink("Edit", "QuestionCreator", new { QuestionNum = question.Number, QuestionnaireId = @Model.Questionnaires[0].ID })</p>
            </li>
            }
        </ol>
        </div>
        //hide the other divs
            for (int i = 1; i < @Model.Questionnaires.Count; i++) 
            {
                var temp = i + 1;
            <div id=@temp class=@Model.Questionnaires[i].ID style="display: none; width: 500px; margin-right: 10px; float: left;">
               
                @using (Html.BeginForm("Index", "StaffingExpert", FormMethod.Post))
                {
                    @Html.LabelFor(model => model.Questionnaires[i].Name)
                    @Html.EditorFor(model => model.Questionnaires[i].Name)
                    @Html.HiddenFor(model => model.Questionnaires[i].ID)
                    <input type="submit" value="Save" />
                }
                
                <ol>
                @foreach (var question in @Model.Questionnaires[i].Questions)
                {
                    <li>
                        <p>@question.GetDisplayText() @Html.ActionLink("Edit", "QuestionCreator", new { QuestionNum = question.Number, QuestionnaireId = @Model.Questionnaires[i].ID })</p>
                    </li>
                 }
                </ol>
            </div>
            }
        break;
}
        
@section Scripts {
    @Scripts.Render("~/bundles/jqueryval")
    
}
